package io.renren;

import cn.smallbun.screw.core.Configuration;
import cn.smallbun.screw.core.engine.EngineConfig;
import cn.smallbun.screw.core.engine.EngineFileType;
import cn.smallbun.screw.core.engine.EngineTemplateType;
import cn.smallbun.screw.core.execute.DocumentationExecute;
import cn.smallbun.screw.core.process.ProcessConfig;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;

import javax.sql.DataSource;
import java.util.ArrayList;
import java.util.List;

/**
 * TODO
 *
 * @author txb
 * @since 2023-11-27 9:18
 */
public class MysqlWord {

    public static void main(String[] args) {
        //数据源
        HikariConfig hikariConfig = new HikariConfig();
        hikariConfig.setDriverClassName("com.mysql.cj.jdbc.Driver");
        hikariConfig.setJdbcUrl("jdbc:mysql://10.1.23.80:33066/zc_yitong_platform_new");
        hikariConfig.setUsername("root");
        hikariConfig.setPassword("4AjHuZn7OnpgYIYh");
        //设置可以获取tables remarks信息
        hikariConfig.addDataSourceProperty("useInformationSchema", "true");
        hikariConfig.setMinimumIdle(2);
        hikariConfig.setMaximumPoolSize(5);
        DataSource dataSource = new HikariDataSource(hikariConfig);
        //生成配置
        EngineConfig engineConfig = EngineConfig.builder()
                //生成文件路径
                .fileOutputDir("C:\\Users\\40659\\Desktop")
                //打开目录
                .openOutputDir(true)
                //文件类型
                .fileType(EngineFileType.WORD)
                //生成模板实现
                .produceType(EngineTemplateType.freemarker)
                //自定义文件名称
                .fileName("众彩益通数据库设计文档-v1.1").build();

        //忽略表
//        ArrayList<String> ignoreTableName = new ArrayList<>();
//        ignoreTableName.add("test_user");
//        ignoreTableName.add("test_group");
        //忽略表前缀
//        ArrayList<String> ignorePrefix = new ArrayList<>();
//        ignorePrefix.add("test_");
        //忽略表后缀
//        ArrayList<String> ignoreSuffix = new ArrayList<>();
//        ignoreSuffix.add("_test");
        List<String> designatedTableNameList = new ArrayList<>();
        designatedTableNameList.add("sc_order_account_period");
        designatedTableNameList.add("bs_car");
        designatedTableNameList.add("bs_driver");
        designatedTableNameList.add("bs_fleet");
        designatedTableNameList.add("de_delivery_note");
        designatedTableNameList.add("de_send_note");
        designatedTableNameList.add("de_send_note_driver");
        designatedTableNameList.add("de_send_note_pictures_videos");
        designatedTableNameList.add("de_send_note_status");
        designatedTableNameList.add("de_total_receipt");
        designatedTableNameList.add("de_total_receipt_status");
        designatedTableNameList.add("ol_order_loss");
        designatedTableNameList.add("ol_order_loss_status");
        designatedTableNameList.add("se_customer_service");
        designatedTableNameList.add("se_message_management");
        designatedTableNameList.add("ao_after_sales_orders");
        designatedTableNameList.add("ao_after_sales_orders_status");

        designatedTableNameList.add("bs_division");
        designatedTableNameList.add("bs_goods");
        designatedTableNameList.add("bs_sale_goods");
        designatedTableNameList.add("bs_sale_goods_unit");
        designatedTableNameList.add("bs_sale_goods_level");
        designatedTableNameList.add("bs_standard_sale_goods");
        designatedTableNameList.add("bs_sale_goods_supplier");
        designatedTableNameList.add("bs_sale_goods_markup_zhongcai");
        designatedTableNameList.add("bs_sale_goods_markup_sales_service");

        designatedTableNameList.add("bs_purchaser");
        designatedTableNameList.add("bs_purchaser_address");
        designatedTableNameList.add("bs_purchaser_orderable_shop");
        designatedTableNameList.add("bs_purchaser_status");

        designatedTableNameList.add("bs_supplier");
        designatedTableNameList.add("bs_supplier_bank_card");
        designatedTableNameList.add("bs_supplier_goods_review");
        designatedTableNameList.add("bs_supplier_goods_review_status");
        designatedTableNameList.add("bs_supplier_status");
        designatedTableNameList.add("bs_supplier_weekend_holiday");
        designatedTableNameList.add("bs_weekend_holiday");

        designatedTableNameList.add("bs_sales_service");
        designatedTableNameList.add("bs_sales_service_bank_card");
        designatedTableNameList.add("bs_sale_goods_shop");

        designatedTableNameList.add("wh_warehousing_in_storage");
        designatedTableNameList.add("wh_warehousing_in_storage_details");
        designatedTableNameList.add("wh_warehousing_inventory_status");
        designatedTableNameList.add("wh_warehousing_out_storage");
        designatedTableNameList.add("wh_warehousing_out_storage_details");
        designatedTableNameList.add("wh_warehousing_return_storage");
        designatedTableNameList.add("wh_warehousing_return_storage_details");
        designatedTableNameList.add("wh_warehousing_return_storage_status");
        designatedTableNameList.add("wh_warehousing_stocktaking");
        designatedTableNameList.add("wh_warehousing_stocktaking_details");
        designatedTableNameList.add("wh_warehousing_stocktaking_status");

        designatedTableNameList.add("ad_advertising_marketing");
        designatedTableNameList.add("bs_message_notification");
        designatedTableNameList.add("bs_message_notification_user");
        designatedTableNameList.add("bs_notice_notification");
        designatedTableNameList.add("bs_notice_notification_user");

        designatedTableNameList.add("sc_order_info");
        designatedTableNameList.add("sc_order_detail");
        designatedTableNameList.add("sc_my_favorite");
        designatedTableNameList.add("sc_shopping_trolley");
        designatedTableNameList.add("sc_order_review_status");
        designatedTableNameList.add("sc_order_status");
        designatedTableNameList.add("sc_order_evaluation");

        designatedTableNameList.add("sp_order");
        designatedTableNameList.add("sp_order_status");

        designatedTableNameList.add("sc_financial_review_processing_form");
        designatedTableNameList.add("sc_financial_review_processing_form_review_status");

        designatedTableNameList.add("pay_business_payment_records");
        designatedTableNameList.add("rc_business_deal");

        designatedTableNameList.add("pay_abc_bank");
        designatedTableNameList.add("pay_abc_bank_no");
        designatedTableNameList.add("pay_abc_account_detail");
        designatedTableNameList.add("pay_abc_receipts");
        designatedTableNameList.add("pay_abc_transfer");

        designatedTableNameList.add("pay_abc_ebus_account_reconciliation");
        designatedTableNameList.add("pay_abc_ebus_pay");
        designatedTableNameList.add("pay_abc_ebus_pay_for_another");
        designatedTableNameList.add("pay_abc_ebus_refund");

        designatedTableNameList.add("sys_dept");
        designatedTableNameList.add("sys_dict_data");
        designatedTableNameList.add("sys_dict_type");
        designatedTableNameList.add("sys_log_error");
        designatedTableNameList.add("sys_log_login");
        designatedTableNameList.add("sys_log_operation");
        designatedTableNameList.add("sys_menu");
        designatedTableNameList.add("sys_oss");
        designatedTableNameList.add("sys_params");
        designatedTableNameList.add("sys_role");
        designatedTableNameList.add("sys_role_data_scope");
        designatedTableNameList.add("sys_role_menu");
        designatedTableNameList.add("sys_role_user");
        designatedTableNameList.add("sys_user");
        designatedTableNameList.add("sys_user_purchaser");
        designatedTableNameList.add("sys_user_sales_service");
        designatedTableNameList.add("sys_user_supplier");
        designatedTableNameList.add("sys_user_token");

        ProcessConfig processConfig = ProcessConfig.builder()
                //指定生成逻辑、当存在指定表、指定表前缀、指定表后缀时，将生成指定表，其余表不生成、并跳过忽略表配置
                //根据名称指定表生成
                .designatedTableName(designatedTableNameList)
                //根据表前缀生成
//                .designatedTablePrefix(new ArrayList<>())
                //根据表后缀生成
//                .designatedTableSuffix(new ArrayList<>())
                //忽略表名
//                .ignoreTableName(ignoreTableName)
                //忽略表前缀
//                .ignoreTablePrefix(ignorePrefix)
                //忽略表后缀
//                .ignoreTableSuffix(ignoreSuffix)
                .build();
        //配置
        Configuration config = Configuration.builder()
                //版本
                .version("1.0")
                //描述
                .description("众彩益通数据库设计文档")
                //数据源
                .dataSource(dataSource)
                //生成配置
                .engineConfig(engineConfig)
                //生成配置
                .produceConfig(processConfig)
                .build();
        //执行生成
        new DocumentationExecute(config).execute();
    }
}
